<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/26
 * Time: 21:19
 */


date_default_timezone_set("PRC");
$file = file( __FILE__ );
foreach ( $file as $item ) {
	file_put_contents( "tmp.txt", $item, FILE_APPEND );
}

//1.php
echo basename( __FILE__ ) . PHP_EOL;
//sudoers
echo "1) " . basename( "/etc/sudoers.d", ".d" ) . PHP_EOL;
//passwd
echo "2) " . basename( "/etc/passwd" ) . PHP_EOL;
//etc
echo "3) " . basename( "/etc/" ) . PHP_EOL;
//.
echo "4) " . basename( "." ) . PHP_EOL;
//
echo "5) " . basename( "/" ) . PHP_EOL;

//E:\PHPSRC\git-src\PHPTEST\2017\06\26
echo dirname( __FILE__ ) . PHP_EOL;

function mb_basename( $file ) {
	$a = explode( DIRECTORY_SEPARATOR, $file );

	return end( $a );
}

//1.php
echo mb_basename( __FILE__ );

copy( __FILE__, '2.php' );

rename( "tmp.txt", "new.txt" );
//sleep(5);
if ( file_exists( "new.txt" ) ) {
	copy( "new.txt", "copy.txt" );
	unlink( "new.txt" );
}
echo PHP_EOL;

echo "disk_free_space " . (int) ( disk_free_space( "C:" ) / 1024 / 1024 / 1024 ) . "G" . PHP_EOL;
echo "disk_total_space " . (int) ( disk_total_space( "C:" ) / 1024 / 1024 / 1024 ) . "G" . PHP_EOL;

echo filesize( __FILE__ ) . PHP_EOL;
echo filetype( __FILE__ ) . PHP_EOL;

if ( ! file_exists( "touch.txt" ) ) {
	touch( "touch.txt", time(), time() + 3600 );
} else {
	echo date("Y-m-d H:i:s",filectime( "touch.txt" )) . PHP_EOL;
	echo date("Y-m-d H:i:s",fileatime( "touch.txt" )) . PHP_EOL;
}

echo date_default_timezone_get().PHP_EOL;

